// pages/Draft/search/search.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    helperList: [],
    indexData: [],
    inputValue: '', //搜索的内容
  },
  inputBind: function (event) {
    this.setData({
      inputValue: event.detail.value
    })
    console.log('bindInput' + this.data.inputValue)

  },
  searchRet: function (e) {
    wx.request({
      url: "http://127.0.0.1:8082/wx/goods/listHt",
      data: {
        keyword: this.data.inputValue

      },
      method: "GET",
      header: {
        'Content-Type': 'application/json; charset=UTF-8',
        // 'X-Litemall-Token': wx.getStorageSync('token')
      },
      success: function (res) {
        wx: wx.redirectTo({
          url: '/pages/MyCover/weiwancheng/weiwancheng?list='+JSON.stringify(res.data.data),
        })
        console.log(res.data.data)
        // that.setData({
        //   // helperList: res.data.data
        // });

      }
    });
  },
  hetongclick: function (e) {
    console.log(1);
    wx.switchTab({
      url: '../../Exam/Exam',
    });
    // wx.navigateTo({
    //   url: '../detailhetong/detailhetong',
    //   success: function(res) {},
    //   fail: function(res) {},
    //   complete: function(res) {},
    // })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.request({
      url: "http://127.0.0.1:8082/wx/search/helper",
      data: {
        // code: res.code,
        // userInfo: e.detail.userInfo

      },
      method: "GET",
      header: {
        'Content-Type': 'application/json; charset=UTF-8',
        'X-Litemall-Token': wx.getStorageSync('token')
      },
      success: function (res) {
        // resolve(res);
        // wx.setStorageSync('userId', res.data.data.userId);
        // wx.setStorageSync('token', res.data.data.token);
        // console.log(res.data)
        console.log(res.data.data)
        that.setData({
          helperList: res.data.data
        });

      }
    });
    wx.request({
      url: "http://127.0.0.1:8082/wx/search/index",
      data: {

      },
      method: "GET",
      header: {
        'Content-Type': 'application/json; charset=UTF-8',
        'X-Litemall-Token': wx.getStorageSync('token')

      },
      success: function (res) {
        console.log(res.data.data)
        that.setData({
          indexData: res.data.data.historyKeywordList
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})